﻿@model PagedList<Core_Goods>
@{
    ViewBag.ParentUrl = "/Goods/Index";
    ViewBag.Title = "商城宝贝";
}
@section breadcrumb
{
    <ul class="breadcrumb">
        <li>
            <i class="ace-icon fa fa-home home-icon"></i>
            <a href="/">首页</a>
        </li>
        <li class="active">@ViewBag.Title</li>
    </ul><!-- .breadcrumb -->
}
<div class="row">
    <div class="col-xs-12">
        <div class="table-responsive">

            <h4 class="pink">
                <i class="ace-icon fa fa-hand-o-right icon-animated-hand-pointer blue"></i>
                <a href="###" role="button" class="green" data-toggle="modal">上架/下架的各种宝贝</a>
            </h4>

            <div class="hr hr-18 dotted hr-double"></div>
            <div class="nav-search" id="nav-search" style="top: 6px;">
                <form class="form-search">
                    <span class="">
                        <input type="text" placeholder="宝贝名称" class="nav-search-input" id="key" name="key" value="@Request.QueryString["key"]">

                    </span>
                    <button type="submit" class="btn btn-info btn-xs">
                        <i class="ace-icon fa fa-search bigger-110"></i>
                        搜索
                    </button>
                </form>
            </div><!-- #nav-search -->
            <!-- PAGE CONTENT BEGINS -->
            <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                <thead>
                    <tr>
                        <th>宝贝名称</th>
                        <th>置顶</th>
                        <th>推荐</th>
                        <th>折扣价</th>
                        <th>原价</th>
                        <th>状态</th>
                        <th>录入时间</th>
                        <th></th>
                    </tr>
                </thead>

                <tbody>
                    @foreach (var obj in Model)
                    {
                        <tr>
                            <td>@obj.G_Name</td>
                            <td>@UtilPartialView.YesOrNo("是", "否", obj.G_Top == 0)</td>
                            <td>@UtilPartialView.YesOrNo("是", "否", obj.G_Recom== 0)</td>
                            <td>@obj.G_PriceDeposit</td>
                            <td>@obj.G_Price</td>
                            <td>@UtilPartialView.OkOrError("上架中", "已下架", obj.G_Status== 0)</td>
                            <td class="hidden-480">@obj.G_Time</td>

                            <td>
                                <div class="hidden-sm hidden-xs btn-group">
                                    <a class="btn btn-xs btn-info tooltip-info" data-rel="tooltip" data-placement="top" title="编辑" href="/Goods/Edit/@obj.G_Id">
                                        <i class="ace-icon fa fa-pencil bigger-120"></i>
                                    </a>
                                    <a class="btn btn-xs btn-danger tooltip-error" data-rel="tooltip" data-placement="top" title="下架" href="###" data-val ="@obj.G_Id" name="delActivity" data-state ="@obj.G_Status">
                                        <i class="ace-icon fa fa-trash-o bigger-120"></i>
                                    </a>
                                </div>

                                <div class="hidden-md hidden-lg">
                                    <div class="inline position-relative">
                                        <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                            <i class="ace-icon fa fa-cog icon-only bigger-110"></i>
                                        </button>

                                        <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                            <li>
                                                <a class="tooltip-success" data-rel="tooltip" title="编辑" href="/Goods/Edit/@obj.G_Id">
                                                    <span class="blue">
                                                        <i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
                                                    </span>
                                                </a>
                                            </li>
                                            <li>
                                                <a href="###" class="tooltip-error" data-rel="tooltip" title="删除" data-val="@obj.G_Id" name="delActivity" data-state="@obj.G_Status">
                                                    <span class="red">
                                                        <i class="ace-icon fa fa-trash-o bigger-120"></i>
                                                    </span>
                                                </a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
        @Html.Pager(Model, new PagerOptions { FirstPageText = "首页", PrevPageText = "上一页", NextPageText = "下一页", LastPageText = "末页", PageIndexParameterName = "id", NumericPagerItemCount = 5, ContainerTagName = "ul", CssClass = "pagination", CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>", DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>", PagerItemTemplate = "<li>{0}</li>", Id = "mvcpager" })
        <!-- PAGE CONTENT ENDS -->
    </div><!-- /.col -->
</div><!-- /.row -->
@section footer{
<script src="/assets/js/bootbox.min.js"></script>
    <script>
        $(function() {

            //冻结商家
            $('a[name="delActivity"]').on('click', function () {
                var state = $(this).data('state');
                if (state==1) {
                    bootbox.alert("此商品已被下架！");
                    return;
                }
                var sid = $(this).data('val');

                bootbox.confirm("确定下架此商品？", function (o) {
                    if (o) {
                        $.post('/Goods/Forzen', { id: sid, status: 1 }, function (o) {
                            if ('ok' == o) {
                                bootbox.alert("商品已被下架！", function () {
                                    //window.location.reload();

                                    location.reload();
                                });
                            }
                        });
                    }
                });
            });
        });
    </script>
}